package com.ruoyi.edge.rule.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.edge.rule.domain.RuleInfoChart;
import com.ruoyi.edge.rule.mapper.RuleInfoChartMapper;
import com.ruoyi.edge.rule.service.RuleInfoChartService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 图形计算规则基本信息
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class RuleInfoChartServiceImpl implements RuleInfoChartService {

    private final RuleInfoChartMapper ruleInfoChartMapper;

    @Override
    public TableDataInfo<RuleInfoChart> listPage(RuleInfoChart ruleInfoChart, PageQuery pageQuery) {

        LambdaQueryWrapper<RuleInfoChart> lqw = new LambdaQueryWrapper<>();
        Page<RuleInfoChart> page = ruleInfoChartMapper.selectPage(pageQuery.build(), lqw);
        return TableDataInfo.build(page);
    }

    @Override
    public R<RuleInfoChart> get(String id) {
        RuleInfoChart ruleInfoChart = ruleInfoChartMapper.selectById(id);
        return R.ok(ruleInfoChart);
    }

    @Override
    public R<String> add(RuleInfoChart ruleInfoChart) {
        ruleInfoChartMapper.insert(ruleInfoChart);
        return R.ok("新增成功");
    }

    @Override
    public R<String> edit(RuleInfoChart ruleInfoChart) {
        ruleInfoChartMapper.updateById(ruleInfoChart);
        return R.ok("修改成功");
    }

    @Override
    public R<String> remove(String id) {
        ruleInfoChartMapper.deleteById(id);
        return R.ok("删除成功");
    }
}
